<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="db.Album"%>
<%@page import="presentation.PresentationsBean"%> 
<%@page import="presentation.Get16ImagesBean"%>
<%@page import="java.util.List"%>
<%@page import="db.Comment"%> 
<%@page import="db.Picture"%> 
<%
	response.setHeader("Pragma", "No-cache");
	response.setDateHeader("Expires", 0);
	response.setHeader("Cache-Control", "no-cache");
%>    
<head>
	<link rel="stylesheet" type="text/css" href="css/styleGallery.css" /> 
	<link rel="stylesheet" type="text/css" href="css/ViewPicture.css" />   
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Промени</title>
</head>
<%  Get16ImagesBean b = new Get16ImagesBean((Integer)session.getAttribute("pageNum"),null); 
List<Album> albums=null;
%>
<body id="bd">
	<div id="container">
		<my:header/>
		<%if (session.getAttribute("user")==null){ %>
		<c:redirect url="Home.jsp" > </c:redirect>
		<my:menulogout/>
		<%}else{ 
		 albums= b.getUserAlbums( (Long)session.getAttribute("userid"));%>
		
		<my:menulogin/>
		<%} %>
		
   		<div id="midcontainer">
   		<%Long picId;
      	try{
      		picId=Long.parseLong(request.getParameter("image"));
      	}catch(Exception e){
      		picId=null;
      	} %>
   <%if(picId!=null){ %>
   			<div id="text"><p><%=b.getPicturePath(Long.parseLong(request.getParameter("image"))) %></p></div>
   			<div id ="arrow">
             <br><br><br><br><br><br><br><br><br><br><br>	
             <%if((Long)session.getAttribute("startPic")==Long.parseLong(request.getParameter("image"))){		
   					%><img  src="img/right_symbol1.png"/><% 
   					}else{%>	
         	            <a href="PrevPageServlet?image=<%=Long.parseLong(request.getParameter("image"))%>&page=<%=session.getAttribute("pageNum")%>"><img  src="img/right_symbol1.png"/> </a>  
   				    <%}%>
     		</div>
      		
      		<div id="picture">	
        		<div style=" text-align:center;">
         			<div class="shadow2">     
         				 <a title="кликни за да видиш оригиналния размер" href="Image?image=<%=request.getParameter("image")%>"><img  src="Image?image=<%=request.getParameter("image")%>&size=m"/> </a>
         			</div>
       		    </div> 	
     	    </div>  
     	 
        	<div id ="arrow">
              <br><br><br><br><br><br><br><br><br><br><br> 
         	          <%  if(((Long)session.getAttribute("endPic")!=null)&&((Long)session.getAttribute("endPic")==Long.parseLong(request.getParameter("image")))){		
   					%><img  src="img/left_symbol1.png"/><% 
   					}else{%>	
         	            <a href="NextPageServlet?image=<%=Long.parseLong(request.getParameter("image"))%>&page=<%=session.getAttribute("pageNum")%>"><img  src="img/left_symbol1.png"/> </a>
   				    <%}%>
     		</div>
            	
       	    <%if (session.getAttribute("user")!=null){ %>
          	<br><br><br><br>
          	<div class="icon">
          	<div class="icon">
         	 	  <li><a title="изтрий" href="#"><img src="img/trash2.png"/></a></li>
      			  <li><a title="редактирай" href="#"><img  src="img/photo1.png"/></a></li>
      		 	  <!--  <li><a title="прикачи към файл" href="#"><img  src="img/mail1.png"/></a></li>-->
          	</div>     
          	</div>
          	<%} %>
 <%} %>        	
          	<%
          	
          	Long commId;
          	try{
          	    commId=Long.parseLong(request.getParameter("commId"));
          	}catch(Exception e){
          		commId=null;
          	}
          	Long albumId;
          	try{
          	    albumId=Long.parseLong(request.getParameter("album_id"));
          	}catch(Exception e){
          		albumId=null;
          	}
          	 %>
           <%if (session.getAttribute("user")!=null){%>	
              <%if(commId!=null){ %>
			<div class="addcomment">
  				<b>Редактирай коментар<b> 
  				<form action="EditCommentServlet?image=<%=picId%>&commId=<%=commId %>" method="post">
                   <input class="box" value="<%= session.getAttribute("oldContent") %>" name="content" size="30" type="text" ">
                   <br><br>
                   <input class="button" value="Редактирай" type="submit">
                </form>
		    </div>
		    <%}else if(albumId!=null){ %>
		     <div class="addcomment">
  				<b>Редактирай  заглавието на пациента<b> 
  				<form action="EditAlbumServlet?album_id=<%=albumId%>" method="post">
                <input class="box" value="<%= session.getAttribute("oldAlbumName") %>" name="albumName" size="92" type="text">
				<br><br>
                <input class="button" value="Редактирай" type="submit">
                </form>
		    </div>
		   
		    <%}else{ %>
		     <div class="addcomment">
  				<b>Редактирай  заглавието на снимка<b> 
  				<form action="EditPictureServlet?image=<%=picId%>" method="post">
                <input class="box" value="<%= session.getAttribute("oldTitle") %>" name="title" size="92" type="text" style="width: 90%">
                <br><br>
                <b>Промени разположението на снимката<b> 
                <select id="combo"  name="album_id"> 
  					<%for(Album al:albums){ %>
    					<option name="<%=al.getAlbumId() %>" value="<%= al.getAlbumId()%>"><%=al.getAlbumName()%></option>
    				<%} %>
  				</select>
  					<br /> <br />
                <input class="button" value="Редактирай" type="submit">
                </form>
		    </div>
		    <%} %>
	<%} %>   
</div><!-- midcontainer -->
<%b.releaseResources(); %>
<my:footer/>
	
</body>
</html>